const path = require('path')

function resolve (dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  lintOnSave: false,
  chainWebpack: config => {
    config.module.rule('svg')
      .exclude.add(resolve('./src/icons'))

    config.module.rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('./src/icons')).end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({ symbolId: 'icon-[name]' })
  },
  css: {
    requireModuleExtension: true,
    loaderOptions: {
      less: {
        modifyVars: {
          // less vars，customize ant design theme
          'primary-color': '#008296',
          'link-color': '#6F48FF'
        },
        // do not remove this line
        javascriptEnabled: true
      }
    }
  },
  /* webpack-dev-server 相关配置 */
  devServer: {
    /* 自动打开浏览器 */
    open: false,
    host: 'sellercentrall.amazon.com',
    port: 80,
    https: false,
    hotOnly: false,

    proxy: {
      '/api': {
        target: 'http://127.0.0.1:8801/',
        // target: 'http://10.150.5.79:8801/',
        changeOrigin: true,
        secure: false, // 如果是https接口，需要配置这个参数
        pathRewrite: {
          ['^' + '/api']: ''
        }
      },
      '/shop': {
        target: 'http://localhost:8801',
        changeOrigin: true,
        secure: false, // 如果是https接口，需要配置这个参数
        pathRewrite: {
          ['^' + '/shop']: ''
        }
      }
    }
  }
}
